<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang = "zh-CN">
<html lang="en">
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Title</title>
    <script src="/sb/js/jquery-1.8.3.js"></script>
    <script>
        function addOne() {
            location.href="/sb/news/toAdd";
        }
    </script>
</head>
<body>
<center>

<h3>新闻列表</h3>
    <input type="button" value="添加" onclick="addOne()">
<table border="1">
    <tr><td>新闻编号</td><td>标题</td><td> 内容 </td><td> 类型 </td><td> 图片 </td><td> 操作 </td> </tr>
    <tr th:each="news : ${newsList}">
        <td id="newsId"  th:text="${news.NEWSID}"></td>
        <td id = "title" th:text="${news.TITLE}"> </td>
        <td id = "content" th:text="${news.CONTENT}"> </td>
        <td id = "typeId" th:text="${news.TYPEID}"></td>
        <td id = "picPath"><img th:src="@{'/news/show?fileName='+${news.PICPATH}}" width="60" height="60">  <a th:href="'/sb/news/downLoad?fileName='+${news.PICPATH}">下载</a> </td>
        <td  > <button th:onclick="|javascript:toUpdate(${news.NEWSID})|" >更新</button>&nbsp;&nbsp;&nbsp;
            <button th:onclick="|javascript:toDelete(${news.NEWSID})|" >删除</button> </td>
    </tr>
</table>
</center>
<script>
    function toUpdate(newsId) {
        location.href="/sb/news/toUpdate?newsId="+newsId;
    }
    function toDelete(newsId) {
        if(confirm("你确定要删除吗？")){
            location.href="/sb/news/toDelete?newsId="+newsId;
        }
    }

</script>
</body>
</html>